function y=funcsavg(z,tauk,taun,b,alpha,fgdp,igdp, phi ,nrate,delta, rho )

thetaf=z(1);
thetai=z(2);
gamma=z(3);
y(1)=-((phi*(delta/(-(alpha*thetaf*(tauk - 1))/(delta + 1/b - 1))^(1/(alpha - 1)) + (thetaf*(alpha*(tauk - 1) - (alpha - 1)*(taun - 1)))/(-(alpha*thetaf*(tauk - 1))/(delta + 1/b - 1))^(alpha/(alpha - 1))) + gamma*rho*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^(gamma - 1))*(-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1))))/((phi*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^gamma*(rho - 1) + gamma*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^(gamma - 1)*(rho - 1)*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)) - 5280))*(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))- nrate;
y(2)=thetaf*(-(phi*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^gamma*(rho - 1) + gamma*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^(gamma - 1)*(rho - 1)*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)) - 5280))/(phi*(delta/(-(alpha*thetaf*(tauk - 1))/(delta + 1/b - 1))^(1/(alpha - 1)) + (thetaf*(alpha*(tauk - 1) - (alpha - 1)*(taun - 1)))/(-(alpha*thetaf*(tauk - 1))/(delta + 1/b - 1))^(alpha/(alpha - 1))) + gamma*rho*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^(gamma - 1)))^(1 - alpha)*(-(phi*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^gamma*(rho - 1) + gamma*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^(gamma - 1)*(rho - 1)*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)) - 5280))/((phi*(delta/(-(alpha*thetaf*(tauk - 1))/(delta + 1/b - 1))^(1/(alpha - 1)) + (thetaf*(alpha*(tauk - 1) - (alpha - 1)*(taun - 1)))/(-(alpha*thetaf*(tauk - 1))/(delta + 1/b - 1))^(alpha/(alpha - 1))) + gamma*rho*thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^(gamma - 1))*(-(alpha*thetaf*(tauk - 1))/(delta + 1/b - 1))^(1/(alpha - 1))))^alpha - fgdp;
y(3)=thetai*((-(delta + 1/b - 1)/(alpha*thetaf*(tauk - 1)))^(alpha/((alpha - 1)*(gamma - 1)))/(-(gamma*thetai*(rho - 1))/(thetaf*(alpha - 1)*(taun - 1)))^(1/(gamma - 1)))^gamma - igdp;
 
end
 